/**
 * 识别微信浏览器
 * [description]
 * @return {[type]} [description]
 */
export const isWeixin = () =>{
	const ua = navigator.userAgent.toLowerCase();
    if(ua.match(/MicroMessenger/i)=="micromessenger") {
        return true;
    } else {
        return false;
    }
}
/**
 * 获取浏览器地址query参数值
 * @param  {[type]} name [description]
 * @return {[type]}      [description]
 */
export const getQuery = (name = "") => {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}
/**
 * 获取schema协议
 * @return {[type]} [description]
 */
export const getSchemaProtocal = () => {
	var schema = "";
	const u = window.navigator.userAgent;
	const isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
	const isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
	if(isAndroid){
		schema = "ivydadreadtool://"
	}else if(isiOS){
		schema = "ivydadReadtool://"
	}else{
		schema = "ivydadreadtool://"
	}
	return schema
}
/**
 * 获取下载地址
 * @return {[type]} [description]
 */
export const getAppDownload = () => {
	var url = "";
	const u = window.navigator.userAgent;
	const isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
	const isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
	if(isAndroid){
		//Android
		if(isWeixin()){
			url = "http://fusion.qq.com/cgi-bin/qzapps/unified_jump?appid=12141370"
		}else{
			url = "http://exploiter.oss-cn-beijing.aliyuncs.com/exploiter/app/android/ReadTool.apk"
		}
	}else if(isiOS){
		// IOS
		if(isWeixin()){
			url = "http://a.app.qq.com/o/simple.jsp?pkgname=com.ivydad.readtool&g_f=991653"
		}else{
			url = "https://itunes.apple.com/us/app/chang-qing-teng-ba-ba-ying/id1021086502?l=zh&ls=1&mt=8"
		}
	}else{
		url = "http://exploiter.oss-cn-beijing.aliyuncs.com/exploiter/app/android/ReadTool.apk"
	}
	return url
}